package com.tdam2014.grupo3;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.NavUtils;
import android.view.Window;

import com.tdam2014.grupo3.entities.PhotoSet;
import com.tdam2014.grupo3.interfaces.PhotoSetSelectionListener;

public class PhotoSetActivity extends Activity implements PhotoSetSelectionListener {
	
	private PhotoSetFragment photoSetFragment;
	public static final String KEY_PHOTO_SET_ID = "photoSetID";

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
		setContentView(R.layout.activity_photo_set);
		
		photoSetFragment = (PhotoSetFragment) getFragmentManager().findFragmentById(R.id.photoSetFragment);
		photoSetFragment.setPhotoSetSelectionListener(this);
		
		getActionBar().setDisplayHomeAsUpEnabled(true);
	}

	@Override
	public void onPhotoSetSelected(PhotoSet photoSet) {
		Intent intent = new Intent(this, PhotoActivity.class);
		intent.putExtra(KEY_PHOTO_SET_ID, photoSet.getId());
		startActivity(intent);
	}
	
	@Override
	public void onBackPressed() {
		NavUtils.navigateUpFromSameTask(this);
	}
}